using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pokemon
{
    public static class LaneManager
    {
        private static List<Lane> _lanes = new List<Lane>();

        public static void Add(Lane lane)
        {            
            _lanes.Add(lane);
        }

        public static void Remove(Lane lane)
        {
            _lanes.Remove(lane);
        }

        public static Unit GetEnemy(Unit unit)
        {
            Blank b = unit.Owner;
            if (b == null)
                return null;

            int r, c;
            b.Owner.AimBlank(b.Position, b.Size, out r, out c);

            Lane l = _lanes[r];
            if (unit is Pokemon)
            {
                Zombie z = l.GetEnemy((Pokemon) unit, c);
                return z;
            }
            Pokemon p = l.GetEnemy((Zombie) unit, c);
            return p;
        }

        public static Lane GetLane(int index)
        {
            if (index >= _lanes.Count)
                return null;
            return _lanes[index];
        }
    }
}
